using FluentNHibernate.AutoMap;
using Webshop20.Domain.Common;
using Webshop20.Domain.Security.Authentication.Core;
using Webshop20.Infrastructure.Persistence.NH.AutoMappings.Conventions.Common;

namespace Webshop20.Infrastructure.Persistence.NH.AutoMappings
{
    public class ForSecurity
    {
        public static AutoPersistenceModel GetPersistenceModel()
        {
            return
                AutoPersistenceModel.MapEntitiesFromAssemblyOf<Account>()
                    .Where(x => x.Namespace == "Webshop20.Domain.Security.Authentication.Core" &&
                                !x.Name.EndsWith("DTO") &&
                                !x.Name.EndsWith("ConstraintSet") &&
                                x.IsSubclassOf(typeof (Entity)))
                    .ConventionDiscovery.AddFromAssemblyOf<IdConvention>()
                    .WithSetup(
                    c =>
                        {
                            c.IsBaseType = bt => bt == typeof(Entity);
                            c.IsComponentType(typeof (ControllQuestion));
                            c.GetComponentColumnPrefix = y => y.Name + "_";
                        }
                    );
        }
    }
}